package cn.java.dao.impl;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import cn.java.entity.Husband;

public class One2OneDaoImpl {
	
	private SqlSession session=null;
	
	@Before
	public void Init() throws IOException{
		//1.启动mybatis框架 
		//SqlSession <---------SqlSessionFactory <---------SqlSessionFactoryBuilder
		SqlSessionFactoryBuilder sfb=new SqlSessionFactoryBuilder();
		//将mybatis.xml文件转化为输入流
		InputStream inputStream= Resources.getResourceAsStream("mybatis.xml");
		SqlSessionFactory ssf=sfb.build(inputStream);
		session=ssf.openSession();
	}
	
	@Test
	public void one2one(){
		List<Husband> lists= session.selectList("cn.java.dao.impl.One2OneDaoImpl.one2one");
		for (Husband husband : lists) {
			System.out.println(husband);
		}
	}
}
